package com.example.github.io.stream.buffer;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class BufferedOutputStreamExample {
    public static void main(String[] args) {
        // 1. FileOutputStream 生成实例
        FileOutputStream fout = null;
        try {
            fout = new FileOutputStream("D:/logs/test.txt");
            // 2. 将fout 传给BufferedOutputStream
            BufferedOutputStream stream = new BufferedOutputStream(fout);
            String s = "welcome to BufferedOutputStream ";
            byte[] bytes = s.getBytes();
            stream.write(bytes);
            stream.flush();
            stream.close();
            fout.close();
            System.out.println("success... ");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
